package com.admin.web.controller;

import com.bayss.core.constant.ResultMsg;
import com.bayss.core.entity.skuTag.SkuTag;
import com.bayss.core.service.sku.SkuTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * sku tag
 */
@RestController
public class SkuTagController  extends ApiBaseController{
    @Autowired
    private SkuTagService skuTagService;

    /**
     * skutag 删除
     * @param ids
     * @return
     */
    @GetMapping(value = "/skuTag/delete.json")
    public ResultMsg delete(String ids) {
        try {
            skuTagService.deleteByIds(ids);
            return ResultMsg.success();
        } catch (Exception e) {
            e.printStackTrace();
            return ResultMsg.fail(250, "提交失败");
        }
    }

    /**
     * skuTag 新增
     * @param skuTag
     * @return
     */
    @PostMapping(value = "/skuTag/add.json")
    public ResultMsg add(@RequestBody SkuTag skuTag) {
        return skuTagService.add(skuTag);
    }

    /**
     * skuTag更新
     * @param skuTag
     * @return
     */
    @PostMapping(value = "/skuTag/update.json")
    public ResultMsg update(@RequestBody SkuTag skuTag) {
        skuTagService.update(skuTag);
        return ResultMsg.success();
    }

    /**
     * skuTag查询全部
     * @return
     */
    @GetMapping(value = "/skuTag/list.json")
    public ResultMsg list() {
        try {
            return ResultMsg.success(skuTagService.list());
        } catch (Exception e) {
            e.printStackTrace();
            return ResultMsg.fail(250, "查询失败");
        }
    }
}
